﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ChargingSystem4.EUc
{

    public class ArcPanel : Panel
    {
        protected override void OnPaint(PaintEventArgs e)
        {
            Pen pen = new Pen(_borderColor, 1);
            int wdh = 7;
            e.Graphics.DrawLine(pen, new Point(wdh, 0), new Point(this.Width - wdh, 0));//上
            e.Graphics.DrawLine(pen, new Point(0, wdh), new Point(0, this.Height - wdh));  //左
            e.Graphics.DrawLine(pen, new Point(this.Width - 1, wdh), new Point(this.Width - 1, this.Height - wdh));//右
            e.Graphics.DrawLine(pen, new Point(wdh, this.Height - 1), new Point(this.Width - wdh, this.Height - 1));//下 

            //Image imgLeftTop = global::ChargingSystem4.Properties.Resources.jiao01;
            //Image imgRightTop = global::ChargingSystem4.Properties.Resources.jiao03;
            //Image imgRightBottom = global::ChargingSystem4.Properties.Resources.jiao03_04;
            //Image imgLeftBottom = global::ChargingSystem4.Properties.Resources.jiao04;

            //e.Graphics.DrawImage(imgLeftTop, new Point(0, 0));
            //e.Graphics.DrawImage(imgRightTop, new Point(this.Width - imgRightTop.Width, 0));
            //e.Graphics.DrawImage(imgRightBottom, new Point(this.Width - imgRightBottom.Width, this.Height - imgRightBottom.Height));
            //e.Graphics.DrawImage(imgLeftBottom, new Point(0, this.Height - imgLeftBottom.Height));
            base.OnPaint(e);
        }

        Color _borderColor = Color.FromArgb(207, 207, 207);
        public Color BorderColor
        {
            get
            {
                return _borderColor;
            }
            set
            {
                _borderColor = value;
                this.Invalidate();
            }
        }
    }


    public class PaintClass
    {
        public static GraphicsPath GetRoundRectangle(Rectangle rectangle, int r)
        {
            int l = 2 * r;
            // 把圆角矩形分成八段直线、弧的组合，依次加到路径中 
            GraphicsPath gp = new GraphicsPath();
            //上边直线
            gp.AddLine(new Point(rectangle.X + r, rectangle.Y), new Point(rectangle.Right - r, rectangle.Y));
            //右上角圆弧
            gp.AddArc(new Rectangle(rectangle.Right - l, rectangle.Y, l, l), 270F, 90F);
            //右边竖线
            gp.AddLine(new Point(rectangle.Right, rectangle.Y + r), new Point(rectangle.Right, rectangle.Bottom - r));
            //右下角圆弧
            gp.AddArc(new Rectangle(rectangle.Right - l, rectangle.Bottom - l, l, l), 0F, 90F);
            //下边直线
            gp.AddLine(new Point(rectangle.Right - r, rectangle.Bottom), new Point(rectangle.X + r, rectangle.Bottom));
            //左下角圆弧
            gp.AddArc(new Rectangle(rectangle.X, rectangle.Bottom - l, l, l), 90F, 90F);
            //左边竖线
            gp.AddLine(new Point(rectangle.X, rectangle.Bottom - r), new Point(rectangle.X, rectangle.Y + r));
            //左上角圆弧
            gp.AddArc(new Rectangle(rectangle.X, rectangle.Y, l, l), 180F, 90F);
            return gp;
        }
    }


}